`timescale 1ns/1ps
`default_nettype none
// 文件名: rtl/hazard_unit.v
//作用：流水线 hazard 检测单元
module hazard_unit(
    input  wire        ex_memread,
    input  wire [4:0]  ex_rd,
    input  wire [4:0]  id_rs1,
    input  wire [4:0]  id_rs2,
    output wire        stall,   // 给 PC.en 和 IF/ID.en 取反
    output wire        flush    // 给 ID/EX.flush
);
    wire hazard = ex_memread && (ex_rd != 5'd0) &&
                 ((ex_rd == id_rs1) || (ex_rd == id_rs2));
    assign stall = hazard;
    assign flush = hazard;
endmodule
`default_nettype wire
